feat(mcp): chart formatting options across all supported chart types#39887
Draft
feat(mcp): chart formatting options across all supported chart types#39887
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #39887 +/- ##
==========================================
- Coverage 64.37% 63.86% -0.51%
==========================================
Files 2569 2583 +14
Lines 134745 136743 +1998
Branches 31278 31522 +244
==========================================
+ Hits 86737 87336 +599
- Misses 46510 47891 +1381
- Partials 1498 1516 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds number/date/currency formatting, axis titles, data labels, legend
position, and color schemes across every chart type MCP currently
generates. Per-chart additions cover the formatting fields each
Superset visualization natively supports:
- XY: currency_format, show_value (data labels), x_axis_time_format
- Pie: currency_format, date_format, legend_orientation
- PivotTable: currency_format, date_format
- MixedTimeseries: color_scheme, currency_format(_secondary),
legend_orientation, show_value
- BigNumber: color_scheme, currency_format, time_format (trendline)
- Table: color_scheme
CurrencyFormat model encapsulates {symbol, symbolPosition} so
callers can pass structured currency input. Also fixes the legend
orientation form_data key in add_legend_config (legendOrientation
is the canonical key consumed by the echarts plugins;
legend_orientation was inert).
Handlebars is intentionally skipped (fully custom HTML template).
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Extends MCP-generated charts to expose Superset's native formatting controls across every chart type MCP currently supports.
Per chart, only fields the Superset viz actually consumes:
currency_format,show_value(data labels),x_axis_time_formatcurrency_format,date_format,legend_orientationcurrency_format,date_formatcolor_scheme,currency_format(+_secondary),legend_orientation,show_valuecolor_scheme,currency_format,time_format(trendline)color_scheme(
color_scheme,AxisConfig.title/format, andLegendConfigalready existed for XY+Pie from the prior commit.) Handlebars is skipped — its rendering is fully template-driven.CurrencyFormatis a new shared pydantic model accepting{symbol, symbol_position}(withsymbolPositionalias) so LLM clients can pass structured currency input. Per-column formatting on Table is out of scope and stays a follow-up — Superset exposes it viacolumn_config, which doesn't fit a single chart-level field.Drive-by fix:
add_legend_configwas writinglegend_orientationto form_data, but the echarts plugins readlegendOrientation. The wrong key was inert; chart now respects the user's choice.Example:
{ "dataset_id": 1, "config": { "chart_type": "xy", "x": {"name": "ds"}, "y": [{"name": "val", "aggregate": "SUM"}], "kind": "bar", "currency_format": {"symbol": "USD", "symbol_position": "prefix"}, "show_value": true, "x_axis_time_format": "%Y-%m-%d" } }BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only.
TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/chart/test_chart_utils.py tests/unit_tests/mcp_service/chart/test_new_chart_types.py— 213 pass (38 new for formatting/CurrencyFormat).generate_chart, pass any of the new fields (e.g.currency_format,show_value,legend_orientation) and confirm form_data carries them through to the rendered chart.ADDITIONAL INFORMATION
CurrencyFormatmodel